package com.itheima.project.web;

import com.itheima.project.basic.ResponseWrap;
import com.itheima.project.core.enums.sms.SmsSendEnum;
import com.itheima.project.exception.ProjectException;
import com.itheima.project.face.SmsSendFace;
import com.itheima.project.utils.ResponseWrapBuild;
import com.itheima.project.vo.sms.SendMessageVo;
import com.itheima.project.vo.sms.SmsSendRecordVo;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName SmsSendController.java
 * @Description 短信发送controller
 */
@RestController
@RequestMapping("smsSend")
public class SmsSendController {

    @Autowired
    SmsSendFace smsSendFace;

    /***
     * @description 发送短信:削峰方式
     * @param sendMessageVo 发送对象
     */
    @PostMapping("send-sms-mq")
    @ApiOperation(value = "发送短信：削峰方式",notes = "发送短信：削峰方式")
    @ApiImplicitParam(name = "sendMessageVo",value = "短信发送对象",required = true,dataType = "SendMessageVo")
    ResponseWrap<Boolean> sendSmsForMq(@RequestBody SendMessageVo sendMessageVo) throws ProjectException{
        Boolean flag = smsSendFace.sendSmsForMq(sendMessageVo);
        return ResponseWrapBuild.build(SmsSendEnum.SUCCEED,flag);
    }

    /***
     * @description 发送短信:非削峰方式
     * @param sendMessageVo 发送对象
     */
    @PostMapping("send-sms")
    @ApiOperation(value = "发送短信：非削峰方式",notes = "发送短信：非削峰方式")
    @ApiImplicitParam(name = "sendMessageVo",value = "短信发送对象",required = true,dataType = "SendMessageVo")
    ResponseWrap<Boolean> sendSms(@RequestBody SendMessageVo sendMessageVo) throws ProjectException{
        Boolean flag = smsSendFace.sendSms(sendMessageVo);
        return ResponseWrapBuild.build(SmsSendEnum.SUCCEED,flag);
    }

    /***
     * @description 查询短信发送情况
     * @param smsSendRecordVo 发送记录
     * @return
     */
    @PostMapping("query-send-sms")
    @ApiOperation(value = "查询短信发送情况",notes = "查询短信发送情况")
    @ApiImplicitParam(name = "smsSendRecordVo",value = "短信发送记录",required = true,dataType = "SmsSendRecordVo")
    ResponseWrap<Boolean> querySendSms(SmsSendRecordVo smsSendRecordVo) throws ProjectException{
        Boolean flag = smsSendFace.querySendSms(smsSendRecordVo);
        return ResponseWrapBuild.build(SmsSendEnum.SUCCEED,flag);
    }

    /***
     * @description 重试发送
     * @param smsSendRecordVo
     * @return
     */
    @PostMapping("retry-send-sms")
    @ApiOperation(value = "重试发送",notes = "重试发送")
    @ApiImplicitParam(name = "smsSendRecordVo",value = "短信发送记录",required = true,dataType = "SmsSendRecordVo")
    ResponseWrap<Boolean> retrySendSms(SmsSendRecordVo smsSendRecordVo) throws ProjectException{
        Boolean flag = smsSendFace.retrySendSms(smsSendRecordVo);
        return ResponseWrapBuild.build(SmsSendEnum.SUCCEED,flag);
    }
}
